import dayjs from "dayjs";
import { useEffect, useState } from "react";

interface PropsType {
  temp?: string
}

const CurrentTime: React.FC<PropsType> = ({ temp = "YYYY年MM月DD日 HH时mm分ss秒" }) => {
  const [time, setTime] = useState(
    dayjs().format(temp)
  );
  useEffect(() => {
    setInterval(() => {
      setTime(dayjs().format(temp))
    }, 1000);
  }, []);
  return <span>{time}</span>;
};

export default CurrentTime;
